<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>VS 解决方案目录结构设置 - zuibunan - 博客园</title>
<link type="text/css" rel="stylesheet" href="/bundles/blog-common.css?v=d_Et_wtKX7bJcow-mLRlKv4wqGQ2rjNrWTPvZmUqF8Y1"/>
<link id="MainCss" type="text/css" rel="stylesheet" href="/skins/AnotherEon001/bundle-AnotherEon001.css?v=_m-jLtl6JZTPbqa4gXDwru2bF6vsLtluIVqvc1OQ0ko1"/>
<link title="RSS" type="application/rss+xml" rel="alternate" href="http://www.cnblogs.com/zuibunan/rss"/>
<link title="RSD" type="application/rsd+xml" rel="EditURI" href="http://www.cnblogs.com/zuibunan/rsd.xml"/>
<link type="application/wlwmanifest+xml" rel="wlwmanifest" href="http://www.cnblogs.com/zuibunan/wlwmanifest.xml"/>
<script src="http://common.cnblogs.com/script/jquery.js" type="text/javascript"></script>  
<script type="text/javascript">var currentBlogApp = 'zuibunan', cb_enable_mathjax=false;</script>
<script src="/bundles/blog-common.js?v=dVqr0ue7y29mRAG2afMkFcSk38ChENfNlXrmAf_YHQE1" type="text/javascript"></script>
</head>
<body>
<a name="top"></a>

<div id="wrapper">
<div id="header">

<div id="top">
<h1><a id="Header1_HeaderTitle" class="headermaintitle" href="http://www.cnblogs.com/zuibunan/">醉步男的博客</a></h1>
<div id="subtitle">Email:yin_caoyuan@126.com</div>
</div>
<div id="sub"></div>



</div>
<div id="main_container">
<div id="main_content">
<div id="content">
	

	<div class="post">
		<h2>
			<a id="cb_post_title_url" href="http://www.cnblogs.com/zuibunan/p/3843459.html">VS 解决方案目录结构设置</a>
		</h2>
		<div class="postbody">
		<div id="cnblogs_post_body"><div class="cnblogs_code" style="background-color: #f5f5f5; border: #cccccc 1px solid; padding: 5px;">
<pre><span style="color: #000000;">涉及到的配置：
项目编译时使用的中间目录；
项目链接的输出目录；
项目编译结束后，拷贝生成的 dll 和 lib 到指定目录；
项目编译结束后，拷贝需要的 dll 到输出目录；
设置项目的工作目录；
设置调试时执行的 exe 和工作目录；


配置时使用到的一些宏：
ConfigurationName   配置名字，通常是Debug或者Release
IntDir              编译器使用的中间目录，产出obj文件
OutDir              链接器使用的输出目录
ProjectDir          项目目录
ProjectName         项目名字
SolutionDir         解决方案目录
TargetDir           目标输出文件所在的目录
TargetExt           目标输出的扩展名
TargetFileName      目标输出文件名，包括扩展名
TargetName          目标输出名，不包括扩展名
TargetPath          目标输出文件的全路径名


下面以 Sticker 为例展示目录结构设置的过程：
Sticker 目录结构：
Sticker
    </span>+--<span style="color: #000000;"> 3rd (第三方库)
    </span>|   +--<span style="color: #000000;"> dll
    </span>|   |   +--<span style="color: #000000;"> debug
    </span>|   |   +--<span style="color: #000000;"> release
    </span>|   +--<span style="color: #000000;"> lib
    </span>|   |   +--<span style="color: #000000;"> debug
    </span>|   |   +--<span style="color: #000000;"> release
    </span>|   +--<span style="color: #000000;"> include
    </span>|
    +--<span style="color: #000000;"> src (源码)
    </span>|   +--<span style="color: #000000;"> Sticker
    </span>|   |   +--<span style="color: #000000;"> Sticker 项目的代码
    </span>|   +--<span style="color: #000000;"> StickerLibrary
    </span>|   |   +--<span style="color: #000000;"> StickerLibrary 项目的代码
    </span>|   +--<span style="color: #000000;"> Sticker.sln
    </span>|
    +--<span style="color: #000000;"> xar (脚本)
    </span>|   +--<span style="color: #000000;"> Sticker
    </span>|   +--<span style="color: #000000;"> ...
    </span>|
    +--<span style="color: #000000;"> doc (文档)
    </span>|
    +--<span style="color: #000000;"> bin (可执行文件)
    </span>|   +--<span style="color: #000000;"> debug
    </span>|   +--<span style="color: #000000;"> release
    </span>|
    +--<span style="color: #000000;"> temp (中间目录)
        </span>+--<span style="color: #000000;"> compile
        </span>|   +--<span style="color: #000000;"> debug
        </span>|   +--<span style="color: #000000;"> release
        </span>+--<span style="color: #000000;"> link
            </span>+--<span style="color: #000000;"> debug
            </span>+--<span style="color: #000000;"> release

</span><span style="color: #800080;">1</span><span style="color: #000000;">. 创建文件夹 Sticker\src
</span><span style="color: #800080;">2</span><span style="color: #000000;">. 创建一个空的解决方案 Sticker.sln ，放入 Sticker\src 中
</span><span style="color: #800080;">3</span><span style="color: #000000;">. 创建项目 Sticker
</span><span style="color: #800080;">4</span>. 属性 --&gt;<span style="color: #000000;"> 配置 设定为&ldquo;所有配置&rdquo;，这样可以同时设定 debug\release 下的配置
</span><span style="color: #800080;">5</span>. 配置属性 --&gt; 常规 --&gt;<span style="color: #000000;"> 中间目录： $(SolutionDir)..\temp\compile\$(ConfigurationName)
</span><span style="color: #800080;">6</span>. 配置属性 --&gt; 常规 --&gt;<span style="color: #000000;"> 输出目录： $(SolutionDir)..\temp\link\$(ConfigurationName)
</span><span style="color: #800080;">7</span>. 配置属性 --&gt; C/C++ --&gt; 常规 --&gt; 附加包含目录： <span style="color: #800000;">"</span><span style="color: #800000;">$(SolutionDir)..\3rd\include</span><span style="color: #800000;">"</span>
<span style="color: #800080;">8</span>. 配置属性 --&gt; 链接器 --&gt; 常规 --&gt; 附加库目录： <span style="color: #800000;">"</span><span style="color: #800000;">$(SolutionDir)..\3rd\lib\$(ConfigurationName)</span><span style="color: #800000;">"</span>
<span style="color: #800080;">9</span>. 配置属性 --&gt; 链接器 --&gt; 输入 --&gt;<span style="color: #000000;"> 附加依赖项： xxx1.lib xxx2.lib xxx3.lib
</span><span style="color: #800080;">10</span>. 配置属性 --&gt; 生成事件 --&gt; 生成后事件 --&gt;<span style="color: #000000;"> 命令行： 
    md $(SolutionDir)..\bin\$(ConfigurationName)
    copy $(TargetPath) $(SolutionDir)..\bin\$(ConfigurationName)
    copy $(SolutionDir)..\3rd\dll\$(ConfigurationName) $(SolutionDir)..\bin\$(ConfigurationName)
</span><span style="color: #800080;">11</span>. 配置属性 --&gt; 调试 --&gt;<span style="color: #000000;"> 命令： $(SolutionDir)..\bin\$(ConfigurationName)\$(TargetFileName)
</span><span style="color: #800080;">12</span>. 配置属性 --&gt; 调试 --&gt; 工作目录： $(SolutionDir)..\bin\$(ConfigurationName)\</pre>
</div></div><div id="MySignature"></div>
<div class="clear"></div>
<div id="blog_post_info_block">
<div id="BlogPostCategory"></div>
<div id="EntryTag"></div>
<div id="blog_post_info">
</div>
<div class="clear"></div>
<div id="post_next_prev"></div>
</div>


		</div>
		<p class="postfoot">
			posted on <span id="post-date">2014-07-14 20:42</span> <a href='http://www.cnblogs.com/zuibunan/'>zuibunan</a> 阅读(<span id="post_view_count">...</span>) 评论(<span id="post_comment_count">...</span>)  <a href ="http://i.cnblogs.com/EditPosts.aspx?postid=3843459" rel="nofollow">编辑</a> <a href="#" onclick="AddToWz(3843459);return false;">收藏</a>
		</p>
	</div>
	<script type="text/javascript">var allowComments=true,isLogined=false,cb_blogId=122599,cb_entryId=3843459,cb_blogApp=currentBlogApp,cb_blogUserGuid='3e5bbee1-0a74-e111-aa3f-842b2b196315',cb_entryCreatedDate='2014/7/14 20:42:00';loadViewCount(cb_entryId);</script>
	
	<a name="!comments"></a><div id="blog-comments-placeholder"></div><script type="text/javascript">var commentManager = new blogCommentManager();commentManager.renderComments(0);</script>
<div id="comment_form" class="commentform">
<a name="commentform"></a>
<div id="divCommentShow"></div>
<div id="comment_nav"><span id="span_refresh_tips"></span><a href="javascript:void(0);" id="lnk_RefreshComments" onclick="return RefreshCommentList();">刷新评论</a><a href="#" onclick="return RefreshPage();">刷新页面</a><a href="#top">返回顶部</a></div>
<div id="comment_form_container"></div>
<div class="ad_text_commentbox" id="ad_text_under_commentbox"></div>
<div id="site_nav_under"><a href="http://www.cnblogs.com/" target="_blank" title="开发者的网上家园">博客园首页</a><a href="http://q.cnblogs.com/" target="_blank" title="程序员问答社区">博问</a><a href="http://news.cnblogs.com/" target="_blank" title="IT新闻">新闻</a><a href="http://home.cnblogs.com/ing/" target="_blank">闪存</a><a href="http://job.cnblogs.com/" target="_blank">程序员招聘</a><a href="http://kb.cnblogs.com/" target="_blank">知识库</a></div>
<div id="opt_under_post"></div>
<script type="text/javascript">
    var enableGoogleAd = canShowAdsense(); var googletag = googletag || {}; googletag.cmd = googletag.cmd || [];
    fixPostBodyFormat();
</script>
<div id="ad_under_post_holder">
<script type='text/javascript'>
    var googletag = googletag || {};
    googletag.cmd = googletag.cmd || [];
    (function () {
        if (enableGoogleAd) {
            var gads = document.createElement('script');
            gads.async = true;
            gads.type = 'text/javascript';
            var useSSL = 'https:' == document.location.protocol;
            gads.src = (useSSL ? 'https:' : 'http:') + '//www.googletagservices.com/tag/js/gpt.js';
            var node = document.getElementsByTagName('script')[0];
            node.parentNode.insertBefore(gads, node);
        }
    })();
</script>
<script type='text/javascript'>
    try {
        if (enableGoogleAd) {
            googletag.cmd.push(function () {
                googletag.defineSlot('/1090369/cnblogs_blogpost_C1_sitehome', [300, 250], 'div-gpt-ad-1346480159711-0').addService(googletag.pubads());
                googletag.defineSlot('/1090369/cnblogs_blogpost_C2', [468, 60], 'div-gpt-ad-1410860226396-0').addService(googletag.pubads());
                googletag.pubads().enableSingleRequest();
                googletag.enableServices();
            });
        };
    } catch (e) { }
</script>
<div id="google_ad_c1" class="c_ad_block">
    <div id='div-gpt-ad-1346480159711-0' style='width:300px; height:250px;'>
    <script type='text/javascript'>
        try {
            if (enableGoogleAd) {
                googletag.cmd.push(function () { googletag.display('div-gpt-ad-1346480159711-0'); });            
            } else {
                $('#div-gpt-ad-1346480159711-0').hide();
            }
    } catch (e) { }
    </script>
    </div>
</div>
</div>
<div id="under_post_news"></div>
<div id="google_ad_c2" class="c_ad_block">
<div id='div-gpt-ad-1410860226396-0' style='width:468px; height:60px;'>
<script type='text/javascript'>
try {
    if (enableGoogleAd) {
        googletag.cmd.push(function () { googletag.display('div-gpt-ad-1410860226396-0'); });
    } else {
        $('#div-gpt-ad-1346480159711-0').hide();
    }
} catch (e) { }
</script>
</div>
</div>
<div id="under_post_kb"></div>
<div id="HistoryToday" class="c_ad_block"></div>
<script type="text/javascript">
$(function () {
    loadNewsAndKb();
    loadBlogSignature();
    LoadPostInfoBlock(cb_blogId, cb_entryId, cb_blogApp, cb_blogUserGuid);
    GetPrevNextPost(cb_entryId, cb_blogId, cb_entryCreatedDate);
    loadOptUnderPost();
    GetHistoryToday(cb_blogId, cb_blogApp, cb_entryCreatedDate);
    setTimeout(function () { incrementViewCount(cb_entryId); }, 200);
});
</script>
</div>

</div>
</div>
<div id="leftmenu">


<h3>导航</h3>
<ul>
<li>
<a id="MyLinks1_HomeLink" href="http://www.cnblogs.com/">博客园</a></li>
<li>
<a id="MyLinks1_MyHomeLink" class="two_words" href="http://www.cnblogs.com/zuibunan/">首页</a></li>
<li>
</li>
<li>
</li>
<li>
<a id="MyLinks1_Syndication" class="two_words" href="http://www.cnblogs.com/zuibunan/rss">订阅</a>
<a id="MyLinks1_XMLLink" href="http://www.cnblogs.com/zuibunan/rss"><img src="http://www.cnblogs.com/images/xml.gif" alt="订阅" /></a>
</li>
<li>
<a id="MyLinks1_Admin" class="two_words" rel="nofollow" href="http://i.cnblogs.com/">管理</a></li>
</ul>

<div id="blog-calendar" style="display:none"></div><script type="text/javascript">loadBlogDefaultCalendar();</script>

<div id="blog-sidecolumn"></div><script type="text/javascript">loadBlogSideColumn();</script>

</div>
</div>
<div class="clear"></div>
<div id="footer">

<p id="footer">
	Powered by: 
	<br />
	
	<a id="Footer1_Hyperlink3" NAME="Hyperlink1" href="http://www.cnblogs.com/" style="font-family:Verdana;font-size:12px;">博客园</a>
	<br />
	Copyright &copy; zuibunan
</p>
</div>
</div>

</body>
</html>
